#include "StdAfx.h"
#include "ThreadPool.hpp"

int HpsFramework::Threading::ThreadWorker::run()
{

	if(!this->preProcess())
	{
		return 1;
	}

	while(!this->waitForExit(0))
	{
		if(!this->doProcess())
		{
			if(!this->postProcess())
			{
				return 1;
			}
			return 0;
		}
	}

	if(!this->postProcess())
	{
		return 1;
	}

	return 0;

}

HpsFramework::Threading::ThreadWorker::~ThreadWorker()
{
	this->stop(true);
}

HpsFramework::Threading::ThreadWorker::ThreadWorker()
{

}

bool HpsFramework::Threading::ThreadWorker::postProcess()
{
	return true;
}

bool HpsFramework::Threading::ThreadWorker::preProcess()
{
	return true;
}
